package com.dianplus.biz.security;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.util.Collection;

public class DomainCustomDetails extends User {

    private static final long serialVersionUID = 1L;


//    private final Long storeId;

    private final Long loginId;

    /**
     * @param username
     * @param password
     * @param authorities
     */
//    public DomainCustomDetails(Long id, String username, Long storeId, Long userId, String password, Collection<? extends GrantedAuthority> authorities) {
//        super(username, password, authorities);
//        this.id = id;
//        this.storeId = storeId;
//        this.userId = userId;
//    }

    public DomainCustomDetails( Long loginId, String username,  String password, Collection<? extends GrantedAuthority> authorities) {
        super(username, password, authorities);

        this.loginId = loginId;
    }


//    public Long getStoreId() {
//        return storeId;
//    }

    public Long getLoginId() {
        return loginId;
    }

    public boolean isUserInRole(String authority) {
        return getAuthorities().contains(new SimpleGrantedAuthority(authority));
    }

//    @Override
//    public String toString() {
//        return "DomainCustomDetails{" + id + ',' + storeId + ',' + ',' + userId + ',' + getUsername() + ',' + getAuthorities() + '}';
//    }
}
